package com.cndongtai.dao.impl;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.cndongtai.dao.BaseDao;
import com.cndongtai.dao.inter.LightConfigMapper;
import com.cndongtai.po.LightConfig;

@Repository("lightConfigDao")
public class LightConfigDao extends BaseDao implements LightConfigMapper {

	@Override
	public boolean addLightConfig(LightConfig config) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightConfigMapper operation = sqlSession.getMapper(LightConfigMapper.class);
			return operation.addLightConfig(config);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

	@Override
	public boolean delLightConfig(Integer lightId) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightConfigMapper operation = sqlSession.getMapper(LightConfigMapper.class);
			return operation.delLightConfig(lightId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return false;
	}

	@Override
	public LightConfig queryLightConfigByLightId(Integer lightId) {
		SqlSession sqlSession = getSqlSession();
		try {
			LightConfigMapper operation = sqlSession.getMapper(LightConfigMapper.class);
			return operation.queryLightConfigByLightId(lightId);
		}catch(Exception e) {
			e.printStackTrace();
		}finally {
			sqlSession.close();
		}
		
		return null;
	}

}
